package com.fs.jzzn.pojo;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;

import lombok.Data;
import lombok.EqualsAndHashCode;

import com.fs.base.pojo.PEntity;
import com.fs.base.utils.ExcelUtils;

/**
 * @author TiddlerCJ
 * @desc 工程支出/费用增补申请
 */
@Entity
@Table(name="p_expense")

@Data@EqualsAndHashCode(callSuper=false)
public class Expense extends PEntity {
	private String expenseNo;
	//private String pNo;				//关联对应的单项工程
	//private String costType;		//费用类别
	private String applyDate;		//申请日期
	//private Double money;			//支出金额
	//private String billsNo;			//凭单号
	
	private String pm;				//申请人(项目经理)
	
	private String status;			//状态 待审批/已支付/驳回
	
	@Column(name="msg", columnDefinition = "varchar(200) COMMENT '审批意见'")
	private String msg;				//审批建议
	
	private String department;		//所属部门
	
	private String contractName;		//合同名称(挂靠)
	
	private String processInstanceId; //流程实例Id

	public static List<Expense> excelDataFormat(List<List<String>> data) {
		List<Expense> list = new ArrayList<Expense>();
		for(List<String> rowData: data){
			list.add(excelData2Bean(rowData));
		}
		return list;
	}
	
	//项目编号	支出金额	费用类别	申请日期	申请人	凭单号	备注	状态 
	private static Expense excelData2Bean(List<String> row) {
		row = ExcelUtils.dataLenFomart(row, 10);
		Expense ex = new Expense();
		//ex.setPNo(row.get(0));
		try {
			//Double money = Double.parseDouble(row.get(1));
			//ex.setMoney(money);
		} catch (Exception e) {
			System.err.println("支出金额格式有误："+row.get(1) );
		}
		//ex.setCostType(row.get(2));
		ex.setApplyDate(row.get(3));
		ex.setPm(row.get(4));
		//ex.setBillsNo(row.get(5));
		ex.setRemark(row.get(6));
		ex.setStatus(row.get(7));
		ex.setMsg(row.get(8));
		ex.setDepartment(row.get(9)); 
		return ex;
	}
}
